// 订单号生成系统测试脚本
const testOrders = [
  { type: 'dine_in', isGuest: false, expected: 'CMB-', desc: '堂食会员' },
  { type: 'dine_in', isGuest: true, expected: 'CDI-', desc: '堂食游客' },
  { type: 'takeaway', isGuest: false, expected: 'CMT-', desc: '外带会员' },
  { type: 'takeaway', isGuest: true, expected: 'CTO-', desc: '外带游客' },
  { type: 'delivery', isGuest: false, expected: 'CMD-', desc: '外卖会员' },
  { type: 'delivery', isGuest: true, expected: 'CDL-', desc: '外卖游客' },
  { type: 'reservation', isGuest: false, expected: 'CMR-', desc: '预订会员' },
  { type: 'reservation', isGuest: true, expected: 'CRS-', desc: '预订游客' }
];

console.log('\n=== 订单号生成系统测试 ===');
console.log('测试8种不同类型的订单号生成：\n');

testOrders.forEach((test, index) => {
  console.log(`${index + 1}. ${test.desc} (${test.type})`);
  console.log(`   期望前缀: ${test.expected}`);
  
  const orderData = {
    order_type: test.type,
    payment_method: 'cash',
    items: [{ menu_item_id: 1, quantity: 1 }],
    total: 10.00,
    user_id: test.isGuest ? null : 1
  };
  
  const curlCmd = `curl -s -X POST http://localhost:3000/api/orders -H "Content-Type: application/json" -d '${JSON.stringify(orderData)}'`;
  console.log(`   测试命令: ${curlCmd}`);
  console.log('');
});

console.log('=== 测试说明 ===');
console.log('1. 每个命令应该返回包含正确前缀的订单号');
console.log('2. 序号应该从5200开始递增');
console.log('3. 会员订单 (user_id: 1) 和游客订单 (user_id: null) 应该有不同的前缀');
console.log('\n=== 已知的成功案例 ===');
console.log('- 模拟数据库中已有订单: CMB-5203 (堂食会员)');
console.log('- 新的订单号生成逻辑已经在后端实现并测试通过');